<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>逾期罚息计算</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body style="padding: 0 23px;">
<form id="interest_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">
        <div class="fieldBox col_100">
            <div class="label">请选择日期</div>
            <div class="field">
                <input name="createDate" id="createDate" type="text" class="ui-datepicker" value="${createDate}"
                       validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">当前应付金额</div>
            <div class="field">
                <span id="recAmtNow"></span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">逾期天数</div>
            <div class="field">
                <span id="ovdDays"></span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">应付金额</div>
            <div class="field">
                <span id="recAmt"></span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">罚息金额</div>
            <div class="field">
                <span id="fineAmt"></span>
            </div>
        </div>
    </div>
    <div class="btnsBox" style="text-align: center;">
        <input type="text" style="display: none;" name="cstId" id="cstId" value="${cstId}">
        <span id="interest_Btn" class="sq-button sq-button-round l-dialog-btn-ok">计算</span>
        <span id="close_Btn" class="sq-button sq-button-round l-dialog-btn-ok">关闭</span>
    </div>
</form>

<script type="text/javascript">
    $(function () {
        var arAmt = '${arAmt}';
        $('#recAmtNow').text(FormatMoney(arAmt / 100));
        $('#ovdDays').text(${ovdDay});
        $('#recAmt').text(FormatMoney(arAmt / 100));
        var fineAmt = '${fineAmt}';
        $('#fineAmt').text(FormatMoney(fineAmt / 100));

        $("#interest_form").ligerForm({
            validate: true
        });

        //计算罚息
        $('#interest_Btn').click(function (event) {
            var form = liger.get('interest_form');
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }

            var data = form.getData();
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: '<%=path%>/risk/overdueCollect/doCal.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $('#ovdDays').text(msg.data.maxOverdueDay);
                        arAmt = msg.data.arAmt;
                        $('#recAmt').text(FormatMoney(arAmt / 100));
                        fineAmt = msg.data.fineAmt;
                        $('#fineAmt').text(FormatMoney(fineAmt / 100));
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });

        //关闭
        $('#close_Btn').click(function (event) {
            frameElement.dialog.hide();
        });

    });
</script>

</body>
</html>
